#####################################################################
# File:         IndexedGenericContainer.py
# Product:      KnowledgeEngine
#
# Copyright:    Copyright (c) 2002, Faulkner Technologies.
# Author:       Brian Oliver
#
# Description:  The IndexedGenericContainer interface/mix-in
#               defines standard methods for GenericContainers
#               that provide Component indexing services.  These
#               services are used by the Model and Library classes.
#
# See Also:     Component, Model, Library
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
from Common import *
from GenericContainer import GenericContainer, GenericContainerInfo

#####################################################################
## Zope Library Imports
# (none)
 
#####################################################################
## Python Library Imports
# (none)

#####################################################################
## IndexedGenericContainerInfo Class Definition
class IndexedGenericContainerInfo(GenericContainerInfo):
    """
        Defines the class info methods, defining information about
        the class without needing an instance of the class
    """
    
    #---------------------------------------------------------------#
    
    def getClassName(self):
        """
            Returns the name of the class for which 
            we are providing information.
        """
        return 'IndexedGenericContainer'

    #---------------------------------------------------------------#

    def getDisplayName(self):
        """
            Return a friendly name for the class instances
            (this is used for displaying in lists etc)
        """
    
        return "Indexed Generic Container"
        
    #---------------------------------------------------------------#

    def getIdentityType(self):
        """
            ABSTRACT: Return the identity type.  
            
            This is a short string used for prefixing object identities
        """
        
        return "indexedgenericcontainer"

    #---------------------------------------------------------------#

    def isInstanceOf(self, className):
        """
            Returns if the class is an instance of the specified
            className, or implements the interface specified 
            by the className
        """

        return className == 'IndexedGenericContainer' or GenericContainerInfo.isInstanceOf(self, className)
    
    #---------------------------------------------------------------#

    def onConfigureProperties(self):
        """
            Automatically called by the Knowledge Engine once
            the class has been loaded.  Use this method to register 
            class specific properties using the PropertyReflection interface.
            
            If this class is sub-classed, a call must be made to
            the super-class to ensure super-class properties are
            correctly registered
            
            NOTE: This method is called before ClassInfo.onAfterStartup()            
        """

        #initialise the super-class properties for reflection
        GenericContainerInfo.onConfigureProperties(self)
    
    #---------------------------------------------------------------#

    def onConfigureEvents(self):
        """
            Automatically called by the Knowledge Engine once
            the class has been loaded.  Use this method to register 
            class specific events using the EventReflection interface.
            
            If this class is sub-classed, a call must be made to
            the super-class to ensure super-class properties are
            correctly registered
            
            NOTE: This method is called before ClassInfo.onAfterStartup()            
        """
        

        #initialise the super-class events for reflection
        GenericContainerInfo.onConfigureEvents(self)
        
    #---------------------------------------------------------------#

#####################################################################
## IndexedGenericContainer Class Definition
class IndexedGenericContainer(GenericContainer):
    """
        A class to index and manager a container containing
        Component based objects.
    """

    #---------------------------------------------------------------#

    #ABSTRACT TRANSIENT: a ClassInfo implementation instance to provide info about this class
    _CLASSINFO = IndexedGenericContainerInfo()

    #---------------------------------------------------------------#

    def getComponent(self, identity):
        """
            Return the component with the specified identity,
            otherwise returns None
        """

        return None

    #---------------------------------------------------------------#

    def containsComponent(self, identity):
        """
            Return if the component with the specified identity
            is currently indexed.
        """

        return false
    
    #---------------------------------------------------------------#

    def onAfterAddComponent(self, component, componentContext):
        """
            Handle when a component has beed added somewhere in
            the container.
            
            CALLED: Component.onAfterAdd
        """

        pass

    #---------------------------------------------------------------#

    def onBeforeDeleteComponent(self, component, componentContext):
        """
            Handle when a component is about to be deleted from 
            somewhere with in the container
            
            CALLER: Component.onBeforeDelete
        """

        pass
        
    #---------------------------------------------------------------#

    def getClassInfo(self):
        """
            FINAL: return the ClassInfo instance for the environment
        """
        
        return self._CLASSINFO
    
    #---------------------------------------------------------------#

#####################################################################
## Class Initialisation
# (none)
